<template>
  <div class="body">
    <header class="header">
      <div class="title">
        <img src="../../../assets/images/01_11.png" alt class="img_zuo" @click="back" />
        <div>巡查排查</div>
      </div>
    </header>
    <div class="contant">
      <div class="list">
        <div>街道</div>
        <div class="list_two">{{ data.streetName }}</div>
      </div>
      <div class="list">
        <div>社区</div>
        <div class="list_two">{{ data.communityName }}</div>
      </div>
      <div class="list">
        <div>名称</div>
        <div class="list_two">{{ data.enterpriseName }}</div>
      </div>
      <div class="list">
        <div>地址</div>
        <div class="list_two">{{ data.enterpriseAddress }}</div>
      </div>
      <div class="list">
        <div>负责人</div>
        <div class="list_two">{{ data.enterprisePerson }}</div>
      </div>
      <div class="list">
        <div>电话</div>
        <div class="list_two">{{ data.personPhone }}</div>
      </div>
      <div class="list">
        <div>经营范围</div>
        <div class="list_two">{{ data.businessScope }}</div>
      </div>
      <div class="list">
        <div>类别</div>
        <div class="list_two">{{ data.enterpriseCategory }}</div>
      </div>
      <div class="list">
        <div>巡查记录</div>
        <div class="list_two">{{ data.count }}</div>
      </div>
      <div class="btn-box" v-show="isShow===1">
        <div class="button" @click="nextgo">
          <img class="img_hand" src="../../../assets/images/hand.png" />
          <div>生成巡查清单</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import { Toast } from 'vant';
  export default {
    name: "inspect_detail",
    data() {
      return {
        list: null,
        userId: 2789,//用户id
        nineStoreId: 1255,
        type: 4,//类型
        typenum: '',
        patrolTroubleshootId: "",
        data: {},
        isShow: null
      };
    },
    methods: {
      back() {
        this.$router.back();
      },
      nextgo() {
        this.axios
          .get(this.$global_msg.Url.host + "/Xx/insertPatrolTroubleshoot?id=" + this.nineStoreId + "&userId=" + this.userId + "&type=" + this.type)
          .then(res => {
            console.log(res);
            if (res.data.code == 0) {
              localStorage.removeItem('param_fgd');
              localStorage.removeItem('busheji_list');//页面是否不涉及的缓存
              this.$router.push("/detail_list");
              localStorage.setItem("patrolTroubleshootId", res.data.rows.patrolTroubleshootId);
              let xcdx_map_xcdxObj = {
                id: this.data.id,
                mc: this.data.enterpriseName,
                // s_type_mc: this.data.yt,
                b_type: 'zdqy'
              }
              localStorage.setItem('xcdx_map_xcdxObj', JSON.stringify(xcdx_map_xcdxObj))
              localStorage.setItem("type", this.type)
            } else {
              this.$toast(res.data.msg)
            }
          }).catch(error => {
            this.$terminal._error(error)
          });
      },
      listarry() {
        try {
          plus.nativeUI.showWaiting("正在加载...");

        } catch (e) {
          console.log('plus问题');
        }
        let params = {
          id: this.nineStoreId,
          userId: this.userId,
          type: this.type
        };
        this.axios.get(
          `${this.$global_msg.Url.host}/Xx/selectPatrolTroubleshoot`,
          { params }).then(res => {
            try {
              plus.nativeUI.closeWaiting();
            } catch (e) {
              console.log('plus问题');
            }
            console.log(res);
            if (res.data.code == 200) {
              console.log(JSON.stringify(res.data.rows))
              this.data = res.data.rows.PatrolInfo;
              this.typenum = res.data.rows.PatrolInfo.ytid
              this.isShow = res.data.rows.isShow;
            } else {
              this.$toast(res.data.msg)
            }
          }).catch(error => {
            this.$terminal._error(error)
          });
      }
    },
    created() {
      var _this = this;
      this.userId = localStorage.getItem("userId")//获取访问id
      // alert(this.userId)
      let data = JSON.parse(sessionStorage.getItem("scan_canshu_data"))
      // alert("住改非"+ JSON.stringify(data))
      this.nineStoreId = data.id
      this.type = data.type
      this.listarry();

      //物理返回
      // window.addEventListener("popstate", function(){
      //   _this.back();
      // }, false);
    }
  };
</script>
<style scoped>
  .list_two {
    color: #8e8e8e;
  }

  .jianhouse {
    display: flex;
    align-items: center;
  }

  .jianhouse img {
    width: 0.4rem;
    margin-left: 0.2rem;
  }

  .list {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f2f2f2;
    height: 1.3rem;
    padding: 0 0.4rem;
  }

  .button img {
    width: 0.6rem;
    margin-right: 0.4rem;
  }

  .btn-box {
    position: fixed;
    bottom: 0;
    box-sizing: border-box;
    width: 100%;
    padding: 30px 0;
    background-color: #f2f2f2;
  }

  .button {
    width: 100%;
    height: 1.5rem;
    color: white;
    background-color: #2b6cfe;
    border-radius: 0.105185rem;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .contant {
    margin-top: 1.8519rem;
    border: 1px solid white;
  }

  .header {
    height: 1.8519rem;
    background: #007aff;
    padding-top: 0.8333rem;
    box-sizing: border-box;
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 20;
    font-size: 0.388888rem;
  }

  .title {
    padding: 0 0.3704rem;
    display: flex;
    align-items: center;
    color: #fff;
  }

  .title>div {
    width: 100%;
    font-size: 0.4444rem;
    text-align: center;
  }

  .img_zuo {
    width: 0.2593rem;
    height: 0.463rem;
  }
</style>